# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libquotient
pkgver=0.9.0
pkgrel=0
pkgdesc="Qt library for cross-platform clients for Matrix"
url="https://github.com/quotient-im/libQuotient"
arch="all !armhf"
license="LGPL-2.1-or-later"
depends_dev="
	olm-dev
	qt6-qtbase-dev
	qtkeychain-dev
	"
makedepends="$depends_dev
	cmake
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/quotient-im/libQuotient/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/libQuotient-$pkgver"

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_TESTING=True \
		-DQuotient_INSTALL_TESTS=False
	cmake --build build
}

check() {
	# testolmaccount requires a running Matrix homeserver
	ctest --test-dir build -E "testolmaccount"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# android only
	rm -r "$pkgdir"/usr/share/ndk-modules
}

sha512sums="
7be9c25f4232ea0640f974db95ed67f5f91caaaa883a81fd14b732df4a0cdc8af0569110d641a246d7c8b021726d3086f75d1df836d3a6e5dff3b82b28a2f50e  libquotient-0.9.0.tar.gz
"
